package com.gzq.singleton.exam90;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test90 {

	public static void main(String[] args)
			throws InstantiationException, IllegalAccessException,
			NoSuchMethodException, SecurityException, IllegalArgumentException,
			InvocationTargetException, IOException, ClassNotFoundException {
		DCL90 s1 = DCL90.getSingleton();
		DCL90 s2 = DCL90.getSingleton();

		System.out.println(s1);
		System.out.println(s2);

		Constructor<DCL90> constructor = DCL90.class.getDeclaredConstructor();
		constructor.setAccessible(true);
		DCL90 ns = constructor.newInstance();
		System.out.println(ns);

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ObjectOutputStream oos = new ObjectOutputStream(baos);
		oos.writeObject(s1);

		byte[] buf = baos.toByteArray();

		ByteArrayInputStream in = new ByteArrayInputStream(buf);
		ObjectInputStream ois = new ObjectInputStream(in);
		Object readObject = ois.readObject();
		System.out.println(readObject);
		
	}

}
